#!/usr/bin/perl -w
use DBI;
use mydb;
use function;

#取server的ip地址
sub get_ServerIP {

        $server = shift||"";

	#my_connect();

	$sql = "SELECT * FROM c_server WHERE status = 'normal' and server = ?";

	#when file is upload down fetch row from t_task

	$sth = $dbconn->prepare($sql) or die $dbconn->errstr;

	$sth->execute($server) or die "错误: " . $sth->errstr;

  	while (@data = $sth->fetchrow()) {

  		$IP = $data[4];
		return $IP;
	}
}


sub get_ServerClass {


        $server = shift||"";

        #my_connect();

        $sql = "SELECT * FROM c_server WHERE status = 'normal' and server = ?";

        #when file is upload down fetch row from t_task

        $sth = $dbconn->prepare($sql) or die $dbconn->errstr;

        $sth->execute($server) or die "错误: " . $sth->errstr;

        while (@data = $sth->fetchrow()) {

       		$sclass = $data[5];
        	return $sclass;
	}
}

sub get_ServerPath {
	
        $server = shift||"";

        #my_connect();

        $sql = "SELECT * FROM c_server WHERE status = 'normal' and server = ?";

        #when file is upload down fetch row from t_task

        $sth = $dbconn->prepare($sql) or die $dbconn->errstr;

        $sth->execute($server) or die "错误: " . $sth->errstr;

        while (@data = $sth->fetchrow()) {

        	$path = $data[6];
        	return $path;
	}
}



sub get_ServerStatus {

	$server = shift||"";

        #my_connect();

        $sql = "SELECT * FROM c_server WHERE status = 'normal' and server = ?";

        #when file is upload down fetch row from t_task

        $sth = $dbconn->prepare($sql) or die $dbconn->errstr;

        $sth->execute($server) or die "错误: " . $sth->errstr;

        while (@data = $sth->fetchrow()) {

        	$status = $data[10];
        	return 	$status;
	}
}


sub get_ServerUserPasswd {

        $server = shift||"";

        #my_connect();

        $sql = "SELECT * FROM c_server WHERE status = 'normal' and server = ?";
        
        #when file is upload down fetch row from t_task

        $sth = $dbconn->prepare($sql) or die $dbconn->errstr;

        $sth->execute($server) or die "错误: " . $sth->errstr;

        while (@data = $sth->fetchrow()) {

        	$user = $data[2];
        	$passwd = $data[3];
		@a_ret = ($user, $passwd);
        	return @a_ret;
	}

}

1;
